#include <string>
#include <iostream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
    int i, j, k;
    int T;
    string ins, word;
    cin >> T;
    getline(cin, ins);
    while (T--)
    {
    cout << endl;
  
    
	getline(cin, ins); //读入带有 空格的一句话 Beijing University of Power Tragedy
	stringstream in;
	in<<ins;//读入流中
	while (in >> word)//读入一个字符串不带空格比如Beijing
	{
	    if (word.size() < 3) continue;
	    for (i = 0; i < word.size(); ++i)
		word[i] = toupper(word[i]);
	    if (word != "THE" && word != "FOR" && word != "AND")
		cout << word[0];
	}
	cout << endl;
    }
    return 0;
}


